#!/bin/bash
#Install APC for PHP
# 13.12.28

[ ! -f APC-3.1.9.tgz ] && wget http://pecl.php.net/get/APC-3.1.9.tgz
tar zxf APC-3.1.9.tgz
cd APC-3.1.9
/usr/local/php/bin/phpize
./configure --enable-apc --enable-apc-mmap -with-php-config=/usr/local/php/bin/php-config
make
make install
cd ..

cat >> /usr/local/php/etc/php.d/apc.ini << EOF
[APC]
extension = "/usr/local/php/lib/php/extensions/apc.so"
EOF
#mv /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/apc.so /usr/local/php/lib/php/extensions/apc.so
echo "Moving apc.so to: /usr/local/php/lib/php/extensions/apc.so"
mv /usr/local/php/lib/php/extensions/no-debug*/apc.so /usr/local/php/lib/php/extensions/apc.so
if [ -f /etc/init.d/php-fpm ] ; then
   /etc/init.d/php-fpm restart
   [ "$?" = "0" ] || echo "Please manually restart PHP-FPM."
elif [ -f /etc/init.d/httpd ] ; then
   /etc/init.d/httpd restart
   [ "$?" = "0" ] || echo "Please manually restart Apache."
else
   echo "Please manually restart Apache or PHP-FPM."
fi

